package com.my.controller;


import com.my.bean.OrderVip;
import com.my.bean.RoomSales;
import com.my.bean.User;
import com.my.service.OrderVipService;
import com.my.service.RoomSalesService;
import com.my.service.RoomService;
import com.my.util.SessionUtil;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;
import org.unbescape.html.HtmlEscape;

import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器  房间销售统计
 * </p>
 *
 * @author 崔倩倩
 * @since 2018-09-03
 */
@Controller
@RequestMapping("/roomSales")
public class RoomSalesController {
	@Autowired
    RoomSalesService roomSalesService;

	@Autowired
    OrderVipService orderVipService;



 Logger logger=Logger.getLogger(WorkguidaceController.class);

    /* 查询*/
    @RequestMapping("/selectRoomSales")
    @ResponseBody
    public List<RoomSales> selectRoomSales(HttpSession session){
    List<RoomSales> list = roomSalesService.selectRoomSales();
        return  list;
    }

    /* 查询*/
    @RequestMapping("/findAllOrderVip")
    @ResponseBody
    public List<Map> findAllOrderVip(HttpSession session){
        boolean admin=false;
        //如果事超级管理员  即可查看所有的房间  判断是否为超级管理员
        if(SessionUtil.getSessionUser(session).getRoles().getRoleValue().equals("9f77d5a8-75c6-4d06-adf9-a37e727d491a")){
            admin=true;
        }
        Long areaid=((User)session.getAttribute("user")).getAreaId();
       return  roomSalesService.findAllOrderVip(areaid,admin);
    }


    @RequestMapping("/room")
    public String room(){
        return "room_sales";
    }
}
